Fix: Minor logging uplift for debugging of prompt injection mitigation#7195
Fix: Minor logging uplift for debugging of prompt injection mitigation#7195dorien-koelemeijer merged 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the prompt-injection scanning internals to surface (via logging) whether pattern-based scanning was used as a fallback when ML-based command injection detection isn’t available or fails.
Changes:
- Add a
used_pattern_detectionflag toDetailedScanResultto track when pattern-based scanning was used. - Switch the
tracing::info!fieldhas_patternsto report the fallback-path usage rather than presence of pattern matches. - Propagate
used_pattern_detectionthrough intermediate scan results used to build the final explanation/logging.
| confidence: max_confidence, | ||
| pattern_matches: Vec::new(), | ||
| ml_confidence: Some(max_confidence), | ||
| used_pattern_detection: false, | ||
| }) |
There was a problem hiding this comment.
scan_conversation always sets ml_confidence: Some(max_confidence) even if every classifier call failed (all scan_with_classifier results were None), which makes downstream logic treat this as a real ML signal (and currently reduces tool_confidence by 10% when the value is 0.0). Track whether any classification succeeded (e.g., fold an Option<f32> or keep a success flag) and return ml_confidence: None when there were no successful results.
| monotonic_counter.goose.security_command_classifier_enabled = if command_classifier_enabled { 1 } else { 0 }, | ||
| monotonic_counter.goose.security_prompt_classifier_enabled = if prompt_classifier_enabled { 1 } else { 0 }, |
There was a problem hiding this comment.
Using monotonic_counter.* = if enabled { 1 } else { 0 } is likely to produce confusing metrics (a counter with value 0 is typically a no-op and the name suggests a gauge); consider logging the booleans as normal fields (e.g. command_classifier_enabled = ...) and emitting a separate monotonic_counter metric with value 1 (or separate enabled/disabled counters) so disabled configurations are still observable.
| monotonic_counter.goose.security_command_classifier_enabled = if command_classifier_enabled { 1 } else { 0 }, | |
| monotonic_counter.goose.security_prompt_classifier_enabled = if prompt_classifier_enabled { 1 } else { 0 }, | |
| monotonic_counter.goose.security_classifier_configuration_logged = 1, | |
| security_command_classifier_enabled = command_classifier_enabled, | |
| security_prompt_classifier_enabled = prompt_classifier_enabled, |
* origin/main: (49 commits) chore: show important keys for provider configuration (#7265) fix: subrecipe relative path with summon (#7295) fix extension selector not displaying the correct enabled extensions (#7290) Use the working dir from the session (#7285) Fix: Minor logging uplift for debugging of prompt injection mitigation (#7195) feat(otel): make otel logging level configurable (#7271) docs: add documentation for Top Of Mind extension (#7283) Document gemini 3 thinking levels (#7282) docs: stream subagent tool calls (#7280) Docs: delete custom provider in desktop (#7279) Everything is streaming (#7247) openai: responses models and hardens event streaming handling (#6831) docs: disable ai session naming (#7194) Added cmd to validate bundled extensions json (#7217) working_dir usage more clear in add_extension (#6958) Use Canonical Models to set context window sizes (#6723) Set up direnv and update flake inputs (#6526) fix: restore subagent tool call notifications after summon refactor (#7243) fix(ui): preserve server config values on partial provider config save (#7248) fix(claude-code): allow goose to run inside a Claude Code session (#7232) ...
* origin/main: feat: add GOOSE_SUBAGENT_MODEL and GOOSE_SUBAGENT_PROVIDER config options (#7277) fix(openai): support "reasoning" field alias in streaming deltas (#7294) fix(ui): revert app-driven iframe width and send containerDimensions per ext-apps spec (#7300) New OpenAI event (#7301) ci: add fork guards to scheduled workflows (#7292) fix: allow ollama input limit override (#7281) chore: show important keys for provider configuration (#7265) fix: subrecipe relative path with summon (#7295) fix extension selector not displaying the correct enabled extensions (#7290) Use the working dir from the session (#7285) Fix: Minor logging uplift for debugging of prompt injection mitigation (#7195) feat(otel): make otel logging level configurable (#7271) docs: add documentation for Top Of Mind extension (#7283) Document gemini 3 thinking levels (#7282) docs: stream subagent tool calls (#7280) Docs: delete custom provider in desktop (#7279) # Conflicts: # ui/desktop/src/components/McpApps/McpAppRenderer.tsx
Summary
Type of Change
AI Assistance
Testing
Local/manual testing.